package com.htc.android.footprints.activity;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;

import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.widget.ViewSwitcher;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.htc.android.footprints.commonui.HtcDialog;
import com.htc.android.footprints.provider.FootprintManager;
import com.htc.android.footprints.utils.FootprintUtils;
import com.htc.android.footprints.utils.SettingInfo;
import com.htc.android.footprints.utils.StorageUtil;
import com.htc.android.footprints.utils.camera.FootprintImageManager;
import com.htc.android.footprints.view.DetailView;
import com.htc.android.footprints.vo.Category;
import com.htc.android.footprints.vo.Footprint;

public class DetailViewActivity extends MapActivity
{
  private static final int DELETE_FOOTPRINT_DIALOG = 1;
  private static final int FIRST_LAUNCH_DIALOG = 0;
  private static final int HANDLE_AFTER_SWITCH = 15;
  private static final int HANDLE_INIT_ALL_DATA = 12;
  private static final int HANDLE_INIT_FIRST_DATA = 11;
  private static final int HANDLE_INIT_FIRST_VIEW = 10;
  private static final int HANDLE_PREPARE_DATA = 13;
  private static final int HANDLE_RESET_SHOW_MSG = 14;
  private static final int MENU_ALL_FOOTPRINTS = 0;
  private static final int MENU_DELETE = 3;
  private static final int MENU_EDIT = 2;
  private static final int MENU_EXPORT = 4;
  private static final int MENU_SAVE_AS_CONTACTS = 1;
  private static final int REQUEST_EDIT = 33;
  private static final String TAG = "DetailViewActivity";
  long TE;
  long TS;
  private boolean USE_TRACEVIEW = false;
  private String categoryKey;
  private ArrayList<Footprint> dataList;
  private FootprintManager dbManager;
  private DetailView firstView;
  private boolean isFirst = true;
  private boolean isLanuchByWidget = false;
  private LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(-1, -2);
  private Animation mAnimationLeftIn;
  private Animation mAnimationLeftOut;
  private Animation mAnimationRightIn;
  private Animation mAnimationRightOut;
  private Bitmap mBmp;
  private Footprint mFootprint;
  HorizontalScrollView.Gesture mGesture = new HorizontalScrollView.Gesture()
  {
    public void moveLeft()
    {
      Log.d("DetailViewActivity", "moveLeft");
      if (DetailViewActivity.this.dataList == null);
      while (true)
      {
        return;
        if (!DetailViewActivity.this.switchLock)
        {
          if (1 + DetailViewActivity.this.mItemIndex < DetailViewActivity.this.dataList.size())
          {
            DetailViewActivity.access$408(DetailViewActivity.this);
            if (DetailViewActivity.this.USE_TRACEVIEW)
              Debug.startMethodTracing("/system/tmp/move_left");
            DetailViewActivity.this.stopPlayback();
            DetailViewActivity.this.updateNextData(false);
            DetailViewActivity.this.mViewSwitcher.setInAnimation(DetailViewActivity.this.mAnimationRightIn);
            DetailViewActivity.this.mViewSwitcher.setOutAnimation(DetailViewActivity.this.mAnimationLeftOut);
            DetailViewActivity.this.mViewSwitcher.showNext();
            DetailViewActivity.access$1002(DetailViewActivity.this, true);
            continue;
          }
          if (DetailViewActivity.this.showingMsg)
            continue;
          DetailViewActivity.access$1702(DetailViewActivity.this, true);
          Toast.makeText(DetailViewActivity.this, DetailViewActivity.this.getString(2131361968), 0).show();
          DetailViewActivity.this.mHandler.sendEmptyMessageDelayed(14, 2500L);
          continue;
        }
      }
    }

    public void moveRight()
    {
      Log.d("DetailViewActivity", "moveRight");
      if (DetailViewActivity.this.dataList == null);
      while (true)
      {
        return;
        if (!DetailViewActivity.this.switchLock)
        {
          if ((!DetailViewActivity.this.switchLock) && (DetailViewActivity.this.mItemIndex > 0))
          {
            DetailViewActivity.access$410(DetailViewActivity.this);
            if (DetailViewActivity.this.USE_TRACEVIEW)
              Debug.startMethodTracing("/system/tmp/move_right");
            DetailViewActivity.this.stopPlayback();
            DetailViewActivity.this.updateNextData(true);
            DetailViewActivity.this.mViewSwitcher.setInAnimation(DetailViewActivity.this.mAnimationLeftIn);
            DetailViewActivity.this.mViewSwitcher.setOutAnimation(DetailViewActivity.this.mAnimationRightOut);
            DetailViewActivity.this.mViewSwitcher.showNext();
            DetailViewActivity.access$1002(DetailViewActivity.this, true);
            continue;
          }
          if (DetailViewActivity.this.showingMsg)
            continue;
          DetailViewActivity.access$1702(DetailViewActivity.this, true);
          Toast.makeText(DetailViewActivity.this, DetailViewActivity.this.getString(2131361969), 0).show();
          DetailViewActivity.this.mHandler.sendEmptyMessageDelayed(14, 2500L);
          continue;
        }
      }
    }
  };
  Handler mHandler = new Handler()
  {
    public void handleMessage(Message paramMessage)
    {
      switch (paramMessage.what)
      {
      case 10:
      default:
      case 11:
      case 12:
      case 13:
      case 14:
      case 15:
      }
      while (true)
      {
        return;
        DetailViewActivity.this.initFirstData();
        continue;
        DetailViewActivity.this.initAllData();
        continue;
        DetailViewActivity.this.prepareData();
        continue;
        DetailViewActivity.access$1702(DetailViewActivity.this, false);
        continue;
        DetailViewActivity.this.removeSwitcherMap();
        ((DetailView)DetailViewActivity.this.mViewSwitcher.getCurrentView()).scrollToTop();
        ((DetailView)DetailViewActivity.this.mViewSwitcher.getCurrentView()).updateViewAfterSwitch(DetailViewActivity.this.mMap);
        DetailViewActivity.this.prepareData();
      }
    }
  };
  private Intent mIntent;
  private int mItemIndex;
  private MapView mMap;
  private StorageUtil mStorageUtil;
  private ImageButton mTapMapViewButton;
  private ViewSwitcher mViewSwitcher;
  View.OnClickListener mapButtonListener = new View.OnClickListener()
  {
    public void onClick(View paramView)
    {
      Intent localIntent = new Intent("com.htc.android.footprints.activity.WrapShowOnMapActivity");
      localIntent.putExtra("target", ((DetailView)DetailViewActivity.this.mViewSwitcher.getCurrentView()).getFootprint());
      localIntent.putExtra("DETAILVIEW", true);
      localIntent.putExtra("EXTRA_SORT_BY", DetailViewActivity.this.sortBy);
      localIntent.putExtra("EXTRA_CATEGORY", DetailViewActivity.this.categoryKey);
      localIntent.addFlags(4194304);
      localIntent.addFlags(67108864);
      DetailViewActivity.this.startActivity(localIntent);
    }
  };
  private Bitmap nextBmp;
  private Category nextCategory;
  private Footprint nextData;
  private String nextTextLat;
  private String nextTextLon;
  private Bitmap preBmp;
  private Category preCategory;
  private Footprint preData;
  private String preTextLat;
  private String preTextLon;
  private String searchKey;
  private DetailView secondView;
  private boolean showingMsg = false;
  private String sortBy = "create_time desc";
  private boolean switchLock = true;
  ViewSwitcher.ViewFactory viewFactory = new ViewSwitcher.ViewFactory()
  {
    public View makeView()
    {
      Log.i("DetailViewActivity", "makeView");
      long l1 = System.currentTimeMillis();
      Log.d("DetailViewActivity", "T2 = " + l1);
      DetailView localDetailView = new DetailView(DetailViewActivity.this);
      localDetailView.getScrollView().setGestureCallback(DetailViewActivity.this.mGesture);
      localDetailView.setMapButton(DetailViewActivity.this.mTapMapViewButton);
      long l2 = System.currentTimeMillis();
      Log.d("DetailViewActivity", "T3 = " + l2);
      Log.d("DetailViewActivity", "T3-T2 = " + (l2 - l1));
      return localDetailView;
    }
  };

  private void checkSetting()
  {
    SettingInfo localSettingInfo = SettingInfo.getInstance(this);
    if (localSettingInfo.isFirstLaunch())
    {
      showDialog(0);
      localSettingInfo.setFirstLaunch(false);
    }
  }

  private void createAnimation()
  {
    this.mAnimationRightIn = AnimationUtils.loadAnimation(this, 2130968592);
    this.mAnimationRightIn.setInterpolator(new DecelerateInterpolator(1.8F));
    this.mAnimationRightIn.setAnimationListener(new Animation.AnimationListener()
    {
      public void onAnimationEnd(Animation paramAnimation)
      {
        if (DetailViewActivity.this.USE_TRACEVIEW)
          Debug.stopMethodTracing();
        DetailViewActivity.this.mHandler.sendEmptyMessage(15);
      }

      public void onAnimationRepeat(Animation paramAnimation)
      {
      }

      public void onAnimationStart(Animation paramAnimation)
      {
      }
    });
    this.mAnimationLeftIn = AnimationUtils.loadAnimation(this, 2130968590);
    this.mAnimationLeftIn.setInterpolator(new DecelerateInterpolator(1.8F));
    this.mAnimationLeftIn.setAnimationListener(new Animation.AnimationListener()
    {
      public void onAnimationEnd(Animation paramAnimation)
      {
        if (DetailViewActivity.this.USE_TRACEVIEW)
          Debug.stopMethodTracing();
        DetailViewActivity.this.mHandler.sendEmptyMessage(15);
      }

      public void onAnimationRepeat(Animation paramAnimation)
      {
      }

      public void onAnimationStart(Animation paramAnimation)
      {
      }
    });
    this.mAnimationLeftOut = AnimationUtils.loadAnimation(this, 2130968591);
    this.mAnimationLeftOut.setInterpolator(new DecelerateInterpolator(1.8F));
    this.mAnimationRightOut = AnimationUtils.loadAnimation(this, 2130968593);
    this.mAnimationRightOut.setInterpolator(new DecelerateInterpolator(1.8F));
  }

  private void initAllData()
  {
    Log.i("DetailViewActivity", "initData");
    long l = System.currentTimeMillis();
    Log.d("DetailViewActivity", "T6 = " + l);
    this.dbManager = FootprintManager.getInstance(this);
    new Thread(new Runnable(l)
    {
      public void run()
      {
        DetailViewActivity.access$102(DetailViewActivity.this, DetailViewActivity.this.mIntent.getStringExtra("EXTRA_SEARCH_INPUT"));
        DetailViewActivity.access$302(DetailViewActivity.this, DetailViewActivity.this.mIntent.getStringExtra("EXTRA_CATEGORY"));
        DetailViewActivity.access$402(DetailViewActivity.this, DetailViewActivity.this.mIntent.getIntExtra("EXTRA_ITEM_IDX", 0));
        String str = DetailViewActivity.this.mIntent.getStringExtra("EXTRA_SORT_BY");
        if (str != null)
          DetailViewActivity.access$502(DetailViewActivity.this, str);
        if (DetailViewActivity.this.searchKey != null)
        {
          Cursor localCursor = DetailViewActivity.this.dbManager.getCursorSortBy(DetailViewActivity.this.categoryKey, DetailViewActivity.this.searchKey, DetailViewActivity.this.sortBy);
          if (localCursor.getCount() > 0)
          {
            DetailViewActivity.access$702(DetailViewActivity.this, new ArrayList(localCursor.getCount()));
            while (localCursor.moveToNext())
            {
              Footprint localFootprint2 = new Footprint();
              FootprintManager.fillDataFromCursor(localFootprint2, localCursor);
              DetailViewActivity.this.dataList.add(localFootprint2);
            }
          }
          localCursor.close();
          if (DetailViewActivity.this.dataList == null)
            Log.e("DetailViewActivity", "initData, dataList = null !");
        }
        while (true)
        {
          long l1 = System.currentTimeMillis();
          Log.d("DetailViewActivity", "T7 = " + l1);
          Log.d("DetailViewActivity", "T7-T6 = " + (l1 - this.val$T6));
          DetailViewActivity.this.createAnimation();
          DetailViewActivity.this.prepareData();
          long l2 = System.currentTimeMillis();
          Log.d("DetailViewActivity", "T8 = " + l2);
          Log.d("DetailViewActivity", "T8-T7 = " + (l2 - l1));
          DetailViewActivity.access$1002(DetailViewActivity.this, false);
          return;
          ArrayList localArrayList = DetailViewActivity.this.dbManager.getFootprintAll(DetailViewActivity.this.sortBy);
          DetailViewActivity.access$702(DetailViewActivity.this, new ArrayList());
          if ((DetailViewActivity.this.categoryKey == null) || (DetailViewActivity.this.categoryKey.length() == 0))
            DetailViewActivity.this.dataList.addAll(localArrayList);
          while (true)
          {
            Log.d("DetailViewActivity", "List Size = " + DetailViewActivity.this.dataList.size());
            Log.d("DetailViewActivity", "mItemIndex = " + DetailViewActivity.this.mItemIndex);
            Log.d("DetailViewActivity", "mFootprint name = " + DetailViewActivity.this.mFootprint.mName);
            if ((DetailViewActivity.this.mFootprint == null) || (DetailViewActivity.this.mItemIndex >= 0))
              break;
            int i = 0;
            while (true)
              if (i < DetailViewActivity.this.dataList.size())
              {
                Log.d("DetailViewActivity", "id/name = " + i + "/" + ((Footprint)DetailViewActivity.this.dataList.get(i)).mName);
                if (((Footprint)DetailViewActivity.this.dataList.get(i)).mName.equals(DetailViewActivity.this.mFootprint.mName))
                  DetailViewActivity.access$402(DetailViewActivity.this, i);
                i++;
                continue;
                Iterator localIterator = localArrayList.iterator();
                while (localIterator.hasNext())
                {
                  Footprint localFootprint1 = (Footprint)localIterator.next();
                  if (!localFootprint1.mCategory.equals(DetailViewActivity.this.categoryKey))
                    continue;
                  DetailViewActivity.this.dataList.add(localFootprint1);
                }
                break;
              }
            Log.d("DetailViewActivity", "after loop, mItemIndex = " + DetailViewActivity.this.mItemIndex);
          }
          if (DetailViewActivity.this.dataList.size() > 0)
            continue;
          Log.e("DetailViewActivity", "initData, dataList size = 0 !");
        }
      }
    }).start();
    this.mStorageUtil = new StorageUtil(getApplicationContext());
    this.mStorageUtil.SetOnChangeStorageListerner(new StorageUtil.OnChangeStorageListener()
    {
      public void onStorageChanged(int paramInt)
      {
        if (paramInt > 1)
          DetailViewActivity.this.startActivity(FootprintUtils.getResetIntent());
      }
    });
    checkSetting();
  }

  private void initFirstData()
  {
    Log.i("DetailViewActivity", "initFirstData");
    this.mMap = new MapView(this, "0ypVfVYlpVnaOTgZc5qugACY0NfEh84HL35r6Wg");
    createMapButton();
    this.firstView.setMapButton(this.mTapMapViewButton);
    this.firstView.updateViewAfterSwitch(this.mMap);
    this.secondView = new DetailView(this);
    this.secondView.setMapButton(this.mTapMapViewButton);
    this.mViewSwitcher.addView(this.secondView, 1, this.lp);
    initAllData();
  }

  private void initFirstView()
  {
    Log.i("DetailViewActivity", "initFirstView");
    long l1 = System.currentTimeMillis();
    Log.d("DetailViewActivity", "T4 = " + l1);
    long l2 = System.currentTimeMillis();
    DetailView localDetailView = new DetailView(this);
    this.firstView = localDetailView;
    long l3 = System.currentTimeMillis();
    Log.d("DetailViewActivity", "create view = " + (l3 - l2));
    this.mViewSwitcher.addView(this.firstView, 0, this.lp);
    this.mFootprint = ((Footprint)this.mIntent.getParcelableExtra("DATA"));
    File localFile = null;
    if (this.mFootprint.mPicPath != null)
      localFile = new File(this.mFootprint.mPicPath);
    this.mBmp = FootprintImageManager.getInstance().getScaledImage(localFile, this, 120, 120, false);
    String str1 = FootprintUtils.getFormatedLat(this.mFootprint.mLatitude);
    String str2 = FootprintUtils.getFormatedLon(this.mFootprint.mLongitude);
    Category localCategory = FootprintManager.getInstance(this).findCategory(this.mFootprint.mCategory);
    this.firstView.setFootprint(this.mFootprint);
    this.firstView.setPicture(this.mBmp);
    this.firstView.setLocationString(str1, str2);
    this.firstView.setCategory(localCategory);
    this.firstView.updateViewBeforeSwitch();
    long l4 = System.currentTimeMillis();
    Log.d("DetailViewActivity", "T5 = " + l4);
    Log.d("DetailViewActivity", "T5-T4 = " + (l4 - l1));
    this.mHandler.sendEmptyMessageDelayed(11, 500L);
  }

  private void prepareData()
  {
    if (this.dataList == null)
      Log.e("DetailViewActivity", "prepareData, dataList = null !");
    while (true)
    {
      return;
      if (1 + this.mItemIndex < this.dataList.size())
      {
        this.nextData = ((Footprint)this.dataList.get(1 + this.mItemIndex));
        if (this.nextData.mPicPath != null)
        {
          File localFile2 = new File(this.nextData.mPicPath);
          this.nextBmp = FootprintImageManager.getInstance().getScaledImage(localFile2, this, 120, 120, false);
        }
        this.nextCategory = FootprintManager.getInstance(this).findCategory(this.nextData.mCategory);
        this.nextTextLat = FootprintUtils.getFormatedLat(this.nextData.mLatitude);
        this.nextTextLon = FootprintUtils.getFormatedLon(this.nextData.mLongitude);
      }
      if ((this.mItemIndex - 1 >= 0) && (this.dataList.size() > 0))
      {
        this.preData = ((Footprint)this.dataList.get(this.mItemIndex - 1));
        if (this.preData.mPicPath != null)
        {
          File localFile1 = new File(this.preData.mPicPath);
          this.preBmp = FootprintImageManager.getInstance().getScaledImage(localFile1, this, 120, 120, false);
        }
        this.preCategory = FootprintManager.getInstance(this).findCategory(this.preData.mCategory);
        this.preTextLat = FootprintUtils.getFormatedLat(this.preData.mLatitude);
        this.preTextLon = FootprintUtils.getFormatedLon(this.preData.mLongitude);
      }
      resetSwitchLock();
    }
  }

  private void reloadData()
  {
    if (this.searchKey != null)
    {
      Cursor localCursor = this.dbManager.getCursorSortBy(this.categoryKey, this.searchKey, this.sortBy);
      if (localCursor.getCount() > 0)
      {
        this.dataList = new ArrayList(localCursor.getCount());
        while (localCursor.moveToNext())
        {
          Footprint localFootprint2 = new Footprint();
          FootprintManager.fillDataFromCursor(localFootprint2, localCursor);
          this.dataList.add(localFootprint2);
        }
      }
      localCursor.close();
      if (this.dataList == null)
        Log.e("DetailViewActivity", "initData, dataList = null !");
    }
    while (true)
    {
      return;
      ArrayList localArrayList = this.dbManager.getFootprintAll(this.sortBy);
      this.dataList = new ArrayList();
      if ((this.categoryKey == null) || (this.categoryKey.length() == 0))
        this.dataList.addAll(localArrayList);
      while (true)
      {
        Log.d("DetailViewActivity", "List Size = " + this.dataList.size());
        Log.d("DetailViewActivity", "mItemIndex = " + this.mItemIndex);
        Log.d("DetailViewActivity", "mFootprint name = " + this.mFootprint.mName);
        if ((this.mFootprint == null) || (this.mItemIndex >= 0))
          break;
        int i = 0;
        while (true)
          if (i < this.dataList.size())
          {
            Log.d("DetailViewActivity", "id/name = " + i + "/" + ((Footprint)this.dataList.get(i)).mName);
            if (((Footprint)this.dataList.get(i)).mName.equals(this.mFootprint.mName))
              this.mItemIndex = i;
            i++;
            continue;
            Iterator localIterator = localArrayList.iterator();
            while (localIterator.hasNext())
            {
              Footprint localFootprint1 = (Footprint)localIterator.next();
              if (!localFootprint1.mCategory.equals(this.categoryKey))
                continue;
              this.dataList.add(localFootprint1);
            }
            break;
          }
        Log.d("DetailViewActivity", "after loop, mItemIndex = " + this.mItemIndex);
      }
      if (this.dataList.size() > 0)
        continue;
      Log.e("DetailViewActivity", "initData, dataList size = 0 !");
    }
  }

  private void removeQueuedMessages()
  {
    this.mHandler.removeMessages(10);
    this.mHandler.removeMessages(11);
    this.mHandler.removeMessages(12);
    this.mHandler.removeMessages(13);
    this.mHandler.removeMessages(14);
    this.mHandler.removeMessages(15);
  }

  private void removeSwitcherMap()
  {
    DetailView localDetailView1 = (DetailView)this.mViewSwitcher.getCurrentView();
    if (localDetailView1 != null)
      localDetailView1.removeMap(this.mMap);
    DetailView localDetailView2 = (DetailView)this.mViewSwitcher.getNextView();
    if (localDetailView2 != null)
      localDetailView2.removeMap(this.mMap);
  }

  private void resetSwitchLock()
  {
    this.switchLock = false;
  }

  private void stopPlayback()
  {
    ((DetailView)this.mViewSwitcher.getCurrentView()).closeMediaControl();
  }

  private void updateNextData(boolean paramBoolean)
  {
    DetailView localDetailView = (DetailView)this.mViewSwitcher.getNextView();
    if (paramBoolean)
    {
      this.mFootprint = this.preData;
      localDetailView.setFootprint(this.preData);
      localDetailView.setPicture(this.preBmp);
      localDetailView.setCategory(this.preCategory);
      localDetailView.setLocationString(this.preTextLat, this.preTextLon);
    }
    while (true)
    {
      localDetailView.updateViewBeforeSwitch();
      return;
      this.mFootprint = this.nextData;
      localDetailView.setFootprint(this.nextData);
      localDetailView.setPicture(this.nextBmp);
      localDetailView.setCategory(this.nextCategory);
      localDetailView.setLocationString(this.nextTextLat, this.nextTextLon);
    }
  }

  public void createMapButton()
  {
    this.mTapMapViewButton = ((ImageButton)((LayoutInflater)getSystemService("layout_inflater")).inflate(2130903044, null));
    this.mTapMapViewButton.setBackgroundResource(2130837542);
    this.mTapMapViewButton.setImageResource(2130837674);
    this.mTapMapViewButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    this.mTapMapViewButton.setClickable(true);
    this.mTapMapViewButton.setOnClickListener(this.mapButtonListener);
  }

  protected boolean isRouteDisplayed()
  {
    return false;
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    if (paramIntent == null)
      Log.d("DetailViewActivity", "onActivityResult. intent data is null");
    while (true)
    {
      return;
      if (paramInt1 == 33)
      {
        if (paramIntent.getBooleanExtra("EXTRA_DELETE_FROM_EDIT", false))
          finish();
        if (paramIntent.getParcelableExtra("DATA") != null)
        {
          removeSwitcherMap();
          this.mFootprint = ((Footprint)paramIntent.getParcelableExtra("DATA"));
          File localFile = null;
          if (this.mFootprint.mPicPath != null)
            localFile = new File(this.mFootprint.mPicPath);
          Bitmap localBitmap = FootprintImageManager.getInstance().getScaledImage(localFile, this, 120, 120, false);
          Category localCategory = FootprintManager.getInstance(this).findCategory(this.mFootprint.mCategory);
          String str1 = FootprintUtils.getFormatedLat(this.mFootprint.mLatitude);
          String str2 = FootprintUtils.getFormatedLon(this.mFootprint.mLongitude);
          DetailView localDetailView = (DetailView)this.mViewSwitcher.getCurrentView();
          localDetailView.setFootprint(this.mFootprint);
          localDetailView.setPicture(localBitmap);
          localDetailView.setCategory(localCategory);
          localDetailView.setLocationString(str1, str2);
          localDetailView.updateViewBeforeSwitch();
          localDetailView.updateViewAfterSwitch(this.mMap);
        }
        ((Footprint)this.dataList.get(this.mItemIndex)).copyFrom(this.mFootprint);
        continue;
      }
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    Log.i("DetailViewActivity", "onCreate");
    this.TS = System.currentTimeMillis();
    Log.d("DetailViewActivity", "TS = " + this.TS);
    if (this.USE_TRACEVIEW)
      Debug.startMethodTracing("/system/tmp/create_view");
    requestWindowFeature(1);
    setContentView(2130903050);
    setVolumeControlStream(3);
    this.mIntent = getIntent();
    this.isLanuchByWidget = this.mIntent.getBooleanExtra("LAUNCH_BY_WIDGET", false);
    this.mViewSwitcher = ((ViewSwitcher)findViewById(2131492939));
    long l = System.currentTimeMillis();
    Log.d("DetailViewActivity", "TC = " + l);
    Log.d("DetailViewActivity", "create time = " + (l - this.TS));
    initFirstView();
  }

  protected Dialog onCreateDialog(int paramInt)
  {
    Object localObject;
    if (paramInt == 0)
      localObject = new HtcDialog(this).getWarningDialog();
    while (true)
    {
      return localObject;
      if (paramInt == 1)
      {
        HtcAlertDialog.Builder localBuilder = new HtcAlertDialog.Builder(this).setTitle(getString(2131361957)).setIcon(17301543);
        String str = getString(2131361816);
        Object[] arrayOfObject = new Object[1];
        arrayOfObject[0] = this.mFootprint.mName;
        localObject = localBuilder.setMessage(String.format(str, arrayOfObject)).setPositiveButton(2131361893, new DialogInterface.OnClickListener()
        {
          public void onClick(DialogInterface paramDialogInterface, int paramInt)
          {
            paramDialogInterface.dismiss();
            FootprintUtils.deleteFootprint(DetailViewActivity.this.getApplicationContext(), DetailViewActivity.this.mFootprint);
            DetailViewActivity.this.finish();
          }
        }).setNegativeButton(2131361796, null).create();
        continue;
      }
      localObject = super.onCreateDialog(paramInt);
    }
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    paramMenu.add(0, 0, 0, getString(2131361881)).setIcon(2130837728);
    paramMenu.add(0, 4, 4, getString(2131361825)).setIcon(2130837680);
    paramMenu.add(0, 2, 2, getString(2131361807)).setIcon(2130837679);
    paramMenu.add(0, 3, 3, getString(2131361808)).setIcon(2130837678);
    paramMenu.add(0, 1, 1, getString(2131361972)).setIcon(2130837731);
    return true;
  }

  protected void onDestroy()
  {
    Log.d("DetailViewActivity", "onDestroy");
    removeQueuedMessages();
    this.mStorageUtil = null;
    if (this.dataList != null)
    {
      this.dataList.clear();
      this.dataList = null;
    }
    super.onDestroy();
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if (paramInt == 84)
    {
      Intent localIntent = new Intent(this, SearchActivity.class);
      localIntent.putExtra("EXTRA_CATEGORY", this.categoryKey);
      localIntent.putExtra("EXTRA_SEARCH_INPUT", this.searchKey);
      localIntent.putExtra("EXTRA_SORT_BY", this.sortBy);
      startActivity(localIntent);
    }
    for (boolean bool = true; ; bool = super.onKeyDown(paramInt, paramKeyEvent))
      return bool;
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    int i = paramMenuItem.getItemId();
    if (i == 0)
      startActivity(FootprintUtils.getResetIntent());
    while (true)
    {
      return false;
      if (i == 2)
      {
        Intent localIntent = new Intent("com.htc.android.footprints.activity.FootprintDetailEditActivity");
        Footprint localFootprint = ((DetailView)this.mViewSwitcher.getCurrentView()).getFootprint();
        try
        {
          localIntent.putExtra("DATA", localFootprint);
          startActivityForResult(localIntent, 33);
        }
        catch (Exception localException)
        {
          Log.e("DetailViewActivity", "Disable to launch edit mode");
        }
        continue;
      }
      if (i == 3)
      {
        showDialog(1);
        continue;
      }
      if (i == 4)
      {
        Footprint[] arrayOfFootprint = new Footprint[1];
        arrayOfFootprint[0] = this.mFootprint;
        FootprintUtils.exportKMZ(this, this.mFootprint.mName.replace(" ", "_"), arrayOfFootprint);
        continue;
      }
      if (i != 1)
        continue;
      FootprintUtils.saveAsContacts(getApplicationContext(), this.mFootprint);
    }
  }

  protected void onPause()
  {
    Log.d("DetailViewActivity", "onPause");
    super.onPause();
    if (this.mStorageUtil != null)
      this.mStorageUtil.closeStorgaeUtil();
    stopPlayback();
    int i = 0;
    ArrayList localArrayList;
    if (this.isLanuchByWidget)
      localArrayList = this.dbManager.getFootprintAll("create_time desc");
    for (int j = 0; ; j++)
    {
      if (j < localArrayList.size())
      {
        if (!((Footprint)localArrayList.get(j)).mName.equals(this.mFootprint.mName))
          continue;
        i = j;
      }
      FootprintUtils.saveFootprintIndex(i);
      return;
    }
  }

  protected void onResume()
  {
    Log.i("DetailViewActivity", "onResume");
    if ((!this.isLanuchByWidget) && (FootprintUtils.isResetByWidget()))
    {
      Intent localIntent = new Intent(this, ListModeNewActivity.class);
      localIntent.setFlags(67108864);
      startActivity(localIntent);
      finish();
    }
    super.onResume();
    if (this.mStorageUtil != null)
      this.mStorageUtil.startStorageUtil();
    this.TE = System.currentTimeMillis();
    Log.d("DetailViewActivity", "TE = " + this.TE);
    Log.d("DetailViewActivity", "TE-TS = " + (this.TE - this.TS));
    if (this.USE_TRACEVIEW)
      Debug.stopMethodTracing();
  }
}

/* Location:           E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name:     com.htc.android.footprints.activity.DetailViewActivity
 * JD-Core Version:    0.6.0
 */